(function() {
	var dishCache = new Map();
	dishCache = DishCache.dishCache;

	var dishes;

	dishCache.eachMap(function(key, value) {
		dishes.push(value);

	});

	var dishTable = document.getElementById("dishes");
	var tr;
	dishes.forEach(function(dish, index, dishes) {
		if (index % 3 == 0) {
			tr = document.createElement("tr");

		}
		var td = document.createElement("td");
		var img = document.createElement("img");
		td.id = dish.name;
		img.src = "./images/" + dish.img;
		img.height = 200;
		img.width = 200;
		var btn = document.createElement("button");
		btn.innerHTML = "Buy" + " price:" + dish.price;
		btn.value = dish.price;
		btn.id = td.id;
		btn.onclick = function() {
			buyFood(dish, map)
		};
		var p = document.createElement("p");
		p.innerHTML = dish.dname;
		td.appendChild(img);
		td.appendChild(p);
		td.appendChild(btn);
		tr.appendChild(td);

		if (index % 3 == 0) {
			table.appendChild(tr);
		}
	});

})();